
package com.scs.application.modules.upms.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.scs.application.core.service.BaseServiceImpl;
import com.scs.application.core.utils.StringUtils;
import com.scs.application.modules.upms.entity.WorkbenchBlock;
import com.scs.application.modules.upms.mapper.WorkbenchBlockMapper;
import com.scs.application.modules.upms.request.WorkbenchBlockQueryRequest;
import com.scs.application.modules.upms.service.WorkbenchBlockService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* 工作台区块 service 实现
*/
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class WorkbenchBlockServiceImpl extends BaseServiceImpl<WorkbenchBlockMapper, WorkbenchBlock> implements WorkbenchBlockService {

    @Override
    public List<WorkbenchBlock> list(WorkbenchBlockQueryRequest request) {
        List<WorkbenchBlock> list = this.list(Wrappers.<WorkbenchBlock>query()
                .like(StringUtils.isNotBlank(request.getTitle()), "title", request.getTitle())
            .orderByAsc("sort")
        );
        return list;
    }

    @Override
    public IPage<WorkbenchBlock> page(WorkbenchBlockQueryRequest request) {
        IPage page = this.page(request.getPage(), Wrappers.<WorkbenchBlock>query()
                .like(StringUtils.isNotBlank(request.getTitle()), "title", request.getTitle())
            .orderByAsc("sort")
        );
        return page;
    }
}
